Description:
This sample zooms the current map to the extent of a layer. For simplicity sake, the first layer in the map is used.
How to use:
- Paste the JScript or VBScript code into the Script dialog box (depending on which language is set as the default scripting language).
- Modify the code to get the desired layer.
- Click/Tap the Execute icon.
JScript
Copy Code | |
---|---|
function ZoomToLayer() { var pLayer; if (Map.Layers.Count == 0) return; pLayer = Map.Layers(1); Map.Extent = pLayer.Extent; Map.Refresh(); pLayer = null; } ZoomToLayer(); |
VBScript
Copy Code | |
---|---|
Sub ZoomToLayer() Dim pLayer If Map.Layers.Count = 0 Then Exit Sub Set pLayer = Map.Layers(1) Map.Extent = pLayer.Extent Map.Refresh Set pLayer = Nothing End Sub Call ZoomToLayer() |